package com.redis;


public class RedisTest2 {
	/**
	 * 订阅发布消息
	 */
	public void subscribe(){
		new Thread(){
			public void run() {
				JedisUtil.subscribe(new Callback(){
					@Override
					public void onMessage(String channel, String message) {//订阅给定模式的频道
						System.out.print("发布A2:"+channel);
						System.out.println("发布A2:"+message);
					}
				},"1d3");
			};
		}.start();
	}
	/**
	 * 订阅队列消息
	 */
	public void subscribeAndRpop(){
		new Thread(){
			public void run() {
				JedisUtil.subscribeAndRpop(new Callback(){
					@Override
					public void onMessage(String channel, String message) {//订阅给定模式的频道
						System.out.print("队列2:"+channel);
						System.out.println(message);
					}
				},"1d3");
			};
		}.start();
	}
	public static void main(String[] args) throws Exception {
		new RedisTest2().subscribeAndRpop();//队列
//		new RedisTest2().subscribe();//普通消息
	}
}
